package com.etc;

import com.etc.pojo.IStudent;
import com.etc.pojo.Student;
import javafx.fxml.Initializable;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

import java.net.URL;
import java.util.Arrays;
import java.util.ResourceBundle;

@SpringBootApplication
public class SpringStart implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(SpringStart.class, args);
    }

    // byte type
    // ApplicationContext:spring核心：  spring容器
    @Autowired
    private ApplicationContext appContext;

    @Override
    public void run(String... args) throws Exception {
        // 获取容器中的bean
//        String[] beans = appContext.getBeanDefinitionNames();
//        Arrays.sort(beans);
//        for (String bean : beans)
//        {
//            System.out.println(bean + " of Type :: " + appContext.getBean(bean).getClass());
//        }
        IStudent stu = appContext.getBean(IStudent.class);
        System.out.println(stu.getName());
    }
}
